package com.ruoyi.home.service.impl;

import com.ruoyi.home.mapper.HomeMapper;
import com.ruoyi.home.service.HomeService;
import com.ruoyi.home.vo.HomeDataVo;
import com.ruoyi.home.vo.HomeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: HomeServiceImpl
 * Description:
 *
 * @Author lh
 * @Create 2024/11/4 10:40
 * @Version 1.0
 */
@Service
public class HomeServiceImpl implements HomeService {
    @Autowired
    private HomeMapper homeMapper;
    @Override
    public HomeDataVo selectHomeData() {
        HomeDataVo homeDataVo = new HomeDataVo();


        // 统计客户来源
        List<HomeVo> customerSources = homeMapper.selectCustomerSource();
        if (!customerSources.isEmpty()) {
            homeDataVo.setSetCustomerSourceList(customerSources);
        }

        // 统计客户行业
        List<HomeVo> customerIndustries = homeMapper.selectCustomerIndustry();
        if (!customerIndustries.isEmpty()) {
            homeDataVo.setSetCustomerIndustryList(customerIndustries);
        }

        // 统计仓库状态
        List<HomeVo> warehouseStatuses = homeMapper.selectWarehouseStatus();
        if (!warehouseStatuses.isEmpty()) {
            homeDataVo.setSetWarehouseStatusList(warehouseStatuses);
        }

        // 统计合计金额
        List<HomeVo> quarterlyTotals = homeMapper.selectYearTotal();
        if (!quarterlyTotals.isEmpty()) {
            homeDataVo.setQuarterlyTotalsList(quarterlyTotals);
        }
        // 统计每月营收金额
        List<HomeVo> totalRevenue = homeMapper.selectTotalRevenue();
        if (!totalRevenue.isEmpty()) {
            homeDataVo.setTotalRevenueList(totalRevenue);
        }
        // 统计合计金额
        List<HomeVo> firstFive = homeMapper.selectFirstFive();
        if (!firstFive.isEmpty()) {
            homeDataVo.setFirstFiveList(firstFive);
        }
        return homeDataVo;
    }
}
